package com.sy.controller;


import com.sy.entity.Chapter;
import com.sy.entity.Question;
import com.sy.entity.Special;
import com.sy.service.MockExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;

@RestController
public class MockExamController extends BaseController {

    /**
     * 专项信息集合
     *
     * @param carTypeId 车型id
     * @param subjectId 科目id
     * @return Special 集合
     */
    @RequestMapping(value = "specials", method = RequestMethod.GET)
    public List<Special> getSpecials(@RequestParam Integer carTypeId, @RequestParam Integer subjectId) {

        return mockExamService.getSpecials(carTypeId, subjectId);
    }


    /**
     * 章节信息集合
     *
     * @param carTypeId 车型id
     * @param subjectId 科目id
     * @return Chapter集合
     */
    @RequestMapping(value = "chapters", method = RequestMethod.GET)
    public List<Chapter> getChapters(@RequestParam Integer carTypeId, @RequestParam Integer subjectId) {
        System.out.println("aaaa");
        return mockExamService.getChapters(carTypeId, subjectId);
    }

    /**
     * 拿到科目一的题目顺序信息
     * @param carTypeId 车型id
     * @param specialId 专项id
     * @param chapterId 章节id
     * @return Question集合
     **/

    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subOne"})
    public List<Question> getSubFirstQuestions(@RequestParam Integer carTypeId, @RequestParam Integer specialId, @RequestParam Integer chapterId) {
        System.out.println("aaaaa");
        return mockExamService.getSubOneQuestions(carTypeId, specialId, chapterId);
    }


    /**
     * 拿到到科目一的题目随机顺序信息
     * @param carTypeId 车型id
     * @param specialId 专项id
     * @param chapterId 章节id
     * @return Question 集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subOneRandom"})
    public List<Question> getSubFirstQuestionsByRandom(@RequestParam Integer carTypeId, @RequestParam Integer specialId, @RequestParam Integer chapterId) {
        System.out.println("aaaaa");
        List<Question> subFirstQuestions = mockExamService.getSubOneQuestions(carTypeId, specialId, chapterId);
        Collections.shuffle(subFirstQuestions);
        return subFirstQuestions;
    }

    /**
     * 获取科目一争议题信息
     * @param carTypeId 车型id
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subOneDispute"})
    public List<Question> getSubOneDispute(@RequestParam Integer carTypeId) {
        return mockExamService.getSubOneDispute(carTypeId);
    }

    /**
     * 获取科目一易错题信息
     * @param carTypeId 车型id
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subOneError"})
    public List<Question> getSubOneError(@RequestParam Integer carTypeId) {
        return mockExamService.getSubOneError(carTypeId);
    }

    /**
     * 模拟考试一百题目
     * @param carTypeId 车型id
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subOneMoNi"})
    public List<Question> getSubOneMoNi(@RequestParam Integer carTypeId) {
        return mockExamService.getSubOneMoNi(carTypeId);
    }

    /**
     * 更新科目一题目错误次数
     * @param qid
     * @return
     */
    @RequestMapping(value = "questions/{qid}",method = RequestMethod.PATCH,params = {"type=updateOne"})
    public boolean updateSubOneWrongNumber(@PathVariable("qid") Integer qid){
        return  mockExamService.updateSubOneWrongNumber(qid);
    }

    /**
     * 拿到科目四的题目顺序信息
     * @param carTypeId 车型id
     * @param specialId 专项id
     * @param chapterId 章节id
     * @return Question集合
     **/

    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subFour"})
    public List<Question> getSubFourQuestions(@RequestParam Integer carTypeId, @RequestParam Integer specialId, @RequestParam Integer chapterId) {
        System.out.println("aaaaa");
        return mockExamService.getSubFourQuestions(carTypeId, specialId, chapterId);
    }


    /**
     * 拿到到科目四的题目随机顺序信息
     * @param carTypeId 车型id
     * @param specialId 专项id
     * @param chapterId 章节id
     * @return Question 集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subFourRandom"})
    public List<Question> getSubFourQuestionsByRandom(@RequestParam Integer carTypeId, @RequestParam Integer specialId, @RequestParam Integer chapterId) {
        System.out.println("aaaaa");
        List<Question> subFourQuestions = mockExamService.getSubFourQuestions(carTypeId, specialId, chapterId);
        Collections.shuffle(subFourQuestions);
        return subFourQuestions;
    }

    /**
     * 获取科目四争议题信息
     * @param carTypeId
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subFourDispute"})
    public List<Question> getSubFourDispute(@RequestParam Integer carTypeId) {
        return mockExamService.getSubFourDispute(carTypeId);
    }

    /**
     * 获取科目四易错题信息
     * @param carTypeId
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subFourError"})
    public List<Question> getSubFourError(@RequestParam Integer carTypeId) {
        return mockExamService.getSubFourError(carTypeId);
    }

    /**
     * 模拟四考试百多题目
     * @param carTypeId 车型id
     * @return Question集合
     */
    @RequestMapping(value = "questions", method = RequestMethod.GET, params = {"type=subFourMoNi"})
    public List<Question> getSubFourMoNi(@RequestParam Integer carTypeId) {
        return mockExamService.getSubFourMoNi(carTypeId);
    }


    /**
     * 更新科目四题目错误次数
     * @param qid
     * @return
     */
    @RequestMapping(value = "questions/{qid}",method = RequestMethod.PATCH,params = {"type=updateFour"})
    public boolean updateSubFourWrongNumber(@PathVariable("qid") Integer qid){
        return  mockExamService.updateSubFourWrongNumber(qid);
    }
}
